<?php
/**
 * 硬件交互
 * Created by PhpStorm.
 * User: Egor <http://gitee.com/seosite>
 * Date: 2018年07月05日
 * Time: 下午21:27
 * Updatetime:
 * updater：
 */
namespace App\Controller;


//加载GatewayClient
require_once './vendor/workerman/GatewayClient/Gateway.php';
use GatewayClient\Gateway;

header('content-type:text/html;charset=utf-8');

class MerTrackController extends BaseController{

    /**
     * @desc 发送消息给单个设备
     * @param $device_id
     * @param $message
     * @author Egor<http://gitee.com/seosite>
     */
    protected function send_message_touid($device_id,$message){
        // 设置GatewayWorker服务的Register服务ip和端口，请根据实际情况改成实际值
        Gateway::$registerAddress = '127.0.0.1:1236';
        // 向任意设备发送数据
        Gateway::sendToUid($device_id, $message);
    }

    /**
     * @desc 发送命令到某个设备
     * @param $order
     * @param $imme
     * @author Egor<http://gitee.com/seosite>
     */
    public function sendMsg($order,$imme)
    {
    	//测试
		//http://llc.bayuenet.com/App/MerTrack/sendMsg?order=B06,7*&imme=868998030913418

		//删除围栏
		//B06,1*

		//添加围栏
		//B05,1,31.532569,120.582653,14000,0,1*

        $send_content = msg_content($order,$imme);
        $this->send_message_touid($imme,$send_content);
    }




}